<template>

    <a-form :form="form">
        <a-form-item label="任务名称" >
            <a-input v-decorator="['jobName',{rules: [{ required: true, message: '请输入任务名称' }]}]"></a-input>
        </a-form-item>

        <a-form-item label="任务类">
            <a-input v-decorator="['jobClass',{rules: [{ required: true, message: '请输入任务类' }]}]"></a-input>
        </a-form-item>

        <a-form-item label="corn表达式">
            <a-input v-decorator="['jobCorn',{rules: [{ required: true, message: '请输入corn表达式' }]}]"></a-input>
        </a-form-item>

    </a-form>
</template>

<script>

    import {Form, DatePicker,Input,Button,Icon,Radio,TreeSelect,message} from 'ant-design-vue';

    export default {
        name: "JobAdd",
        components:{
            ARadioButton:Radio.Button,
            ARadioGroup:Radio.Group,
            AFormItem:Form.Item,
            AForm:Form,
            ADatePicker:DatePicker,
            AInput:Input,
            AButton:Button,
            AIcon:Icon,
            ATreeSelect:TreeSelect
        },
        data() {
            return {
                form: this.$form.createForm(this),
                formItem: {
                    labelCol: {
                        span: 8
                    },
                    wrapperCol: {
                        span: 12
                    }
                }
            }
        },
        methods:{
            submitData() {

                this.form.validateFields((err, fieldsValue) => {
                    if (err) {
                        return false;
                    }


                    let result = {};
                    result.jobName = fieldsValue.jobName;
                    result.jobClass = fieldsValue.jobClass;
                    result.jobCorn = fieldsValue.jobCorn;

                    this.postData(result);
                });
            },

            postData(data){

                this.$axios.post("/schedule/job/addJob",data)
                    .then(d=>{
                        let result = d.data;

                        if(result.status == 0){
                            message.success(result.message);
                            this.$emit("ok");
                        }else{
                            message.error(result.message);
                        }

                    },e=>{
                        message.error("任务创建失败" +e.message);
                    })
            }

        }
    }
</script>

<style scoped>

</style>